how to use ternary in javascript